package com.jiu.http.webqq;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Message {
    /**{"retcode":0,
     *  "result":[{
     *             "poll_type":"group_message",
     *             "value":{"msg_id":9150,
     *                      "from_uin":3085689362,
     *                      "to_uin":348590822,
     *                      "msg_id2":584318,
     *                      "msg_type":43,
     *                      "reply_ip":176756639,
     *                      "group_code":3077268719,
     *                      "send_uin":3736751001,
     *                      "seq":698,
     *                      "time":1388310678,
     *                      "info_seq":113456424,
     *                      "content":[
     *                                 ["font",{"size":11,"color":"800080","style":[0,0,0],"name":"\u9ED1\u4F53"}],
     *                                 "123456789 "]}}]}*/
    private Map<String,Object> msg;   
    private Integer retcode;//0
    private List<Result> result = new ArrayList<Result>();//
    private String p;
    @SuppressWarnings("unchecked")
    public Message(Map<String,Object> msg){
		this.retcode = (Integer) msg.get("retcode");
		//����retcode==0 ʱ��ȡ��Ϣ
		if(retcode==0){	    
		    List<Map<String,Object>> list = (List<Map<String, Object>>) msg.get("result");		    
		    for(Map<String,Object> map:list){
		    	//����ϢΪ���Ѽ�Ⱥ��Ϣʱ
		    	if(map.get("poll_type")!=null//��Ϊ��
		    		&&(map.get("poll_type").equals("message")||map.get("poll_type").equals("group_message")))
		    		result.add(new Result(map));
		    }
		}else if(retcode==116){//�����
		    this.p = (String)msg.get("p");
		}else if(retcode==121||retcode==103){
			//r����
	    }
    }
    public Map<String, Object> getMsg() {
	return msg;
    }
    public void setMsg(Map<String, Object> msg) {
	this.msg = msg;
    }
    public Integer getRetcode() {
	return retcode;
    }
    public void setRetcode(Integer retcode) {
	this.retcode = retcode;
    }
    public List<Result> getResult() {
	return result;
    }
    public void setResult(List<Result> result) {
	this.result = result;
    }
    public String getP() {
	return p;
    }
    public void setP(String p) {
	this.p = p;
    }
}